{include file='public/head'}
<body>
<style type="text/css" media="screen">
    header {
        color: black;
    }
</style>
<div class="x-body">
    <form class="layui-form" id='mainForm' method="post" action="editCategory">

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>分类平台</label>
            <div class="layui-input-block">
                <select name="platform" id='platform' lay-search lay-verify="required">
                    <option value="">请选择平台</option>
                    {volist name='platform' id='vo'}
                    <option value="{$vo.english}" {if $info.platform eq $vo.english} selected {/if}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>分类名称</label>
            <div class="layui-input-block">
                <input type="text" id="bname" name="bname" lay-verify="required" autocomplete="off" value="{$info.bname}"
                       placeholder="请输入分类名" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>智赢分类</label>
            <div class="layui-input-block">
                <input type="radio" name="choose" lay-filter="choose" value="1" title="输入" checked>
                <input type="radio" name="choose" lay-filter="choose" value="2" title="选择"><br><br>
                <div id="zychoose1" class="zychoose">
                    <input type="text" id="zycategory" name="zycategory1" autocomplete="off"
                           placeholder="请输入智赢分类，’/‘连接" class="layui-input" value="{$info.zycategory}">
                </div>
                <div id="zychoose2" class="zychoose" style="display: none">
                    <select lay-filter="zycategory" name="zycategory2" lay-search>
                        <option value="">请选择智赢分类</option>
                        {volist name='zy' id='vo'}
                        <option value="{$vo.name}" {if $vo.name eq $info.zycategory} selected {/if}>{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div>
                <input type="hidden" name="id" id="id" value="{$info.id}">
                <button style="width: 100%" class="layui-btn" lay-submit="" lay-filter="toSubmit">提交保存</button>
            </div>
        </div>


    </form>
</div>
</body>
{include file='public/foot'}
<script type="text/javascript">
    var form = layui.form;
    var layer = layui.layer;
    //监听提交
    form.on('radio(choose)', function (data) {
        $('.zychoose').css('display','none');
        $('#zychoose'+data.value).css('display','block');
    });

    $(document).ready(function () {
        var options = {
            type: 'post',           //post提交
            //url:'http://ask.tongzhuo100.com/server/****.php?='+Math.random(),   //url
            dataType: "json",        //json格式
            data: {},    //如果需要提交附加参数，视情况添加
            clearForm: false,        //成功提交后，清除所有表单元素的值
            resetForm: false,        //成功提交后，重置所有表单元素的值
            cache: false,
            async: false,          //同步返回
            success: function (data) {
                console.log(data);
                if (data.code == 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg(data.msg, {icon: 1, time: 500}, function () {
                        $("#reset").click();
                        x_admin_close();
                        parent.location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };
        // bind form using 'ajaxForm'
        $('#mainForm').ajaxForm(options).submit(function (data) {
            //无逻辑
        });

    });

</script>
